#include "HitsCollection.hh"

HitsCollection::HitsCollection(G4String detName, G4String colName) :
	G4VHitsCollection(detName, colName) {
	size = 0;
	collection = new PMTHit*[0];
}

HitsCollection::~HitsCollection() {
	for (size_t l = 0; l < size; l++)
		delete collection[l];
	delete collection;
}

G4VHit* HitsCollection::GetHit(size_t index) const {
	return collection[index];
}

size_t HitsCollection::GetSize() const {
	return size;
}

void HitsCollection::Insert(PMTHit* newHit) {
	PMTHit** collectionOld = collection;

	collection = new PMTHit*[size + 1];

	for (size_t l = 0; l < size; l++)
		collection[l] = collectionOld[l];
	delete collectionOld;

	size++;

	collection[size - 1] = newHit;
}
